package com.dailyblue.example.springcloud.sentinel.provider.controller;

import com.dailyblue.example.springcloud.commons.util.JsonResult;
import com.dailyblue.example.springcloud.commons.util.ResultTool;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/sentinel_provider")
public class SentinelProviderController {

    @SneakyThrows
    @GetMapping("/a")
    public JsonResult a() {
        log.info("This is SentinelProviderController`a method!");
        Thread.sleep(2000);
        return ResultTool.success("This is SentinelProviderController`a method!");
    }

    @GetMapping("/b")
    public JsonResult b() {
        log.info("This is SentinelProviderController`b method!");
        return ResultTool.success("This is SentinelProviderController`b method!");
    }

    @GetMapping("/c")
    public JsonResult c() {
        log.info("This is SentinelProviderController`c method!");
        return ResultTool.success("This is SentinelProviderController`c method!");
    }
    @GetMapping("/h/{index}")
    public JsonResult h(@PathVariable int index){
        int a = 9 / index;
        return ResultTool.success("This is SentinelProviderController`h method!");
    }
}
